package com.example.demo.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.Entity.Message;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {
    @Select("select * from message where receive_id=#{receiveId}")
    public List<Message> selectByResponseId(Integer receiveId);

    @Delete("delete from message where send_id=#{sendId} and receive_id =#{receiveId} and type=0")
    public void deleteMessage(Integer sendId, Integer receiveId);

    @Select("SELECT * FROM message WHERE (receive_id = #{receiveId} AND send_id = #{sendId}) OR (receive_id = #{sendId} AND send_id = #{receiveId})")
    public List<Message> selectByDialogue(Integer sendId,Integer receiveId);

}
